//
//  JwSkiner.h
//  JwPack
//
//  Created by 陈警卫 on 2024-08-02.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#import "UIView+JwSkiner.h"
#import "UIColor+JwCate.h"
#import "UIColor+JwSkiner.h"
#import "UIImage+JwSkiner.h"

/// 切换主题通知key
#define kJwSkinerNotiKey @"kJwSkinerNotiKey"

#define kJwSkiner [JwSkiner shared]

NS_ASSUME_NONNULL_BEGIN

/// 图片管理方式
typedef NS_ENUM(NSInteger, JwSkinerImageEx) {
    JwSkinerImageExUnknow,
    JwSkinerImageExXcassets, // 通过 xcassets 管理的图片
    JwSkinerImageExBundle,   // 通过 bundle 管理的图片
    /// 通过 xcassets 管理的图片
    /// 图片命名 name_(kJwSkiner_currentSkinKey) ex. power_any, power_dark
    /// 如果设置 后缀别名 则使用对应的后缀别名 ex. power_a, power_d
    ///
    /// 通过 bundle 管理的图片
    /// bundle的名称为kJwSkiner_currentSkinKey 例如 any.bundle, dark.bundle
};

/// MARK: 皮肤管理模型
@interface JwSkinerModel : NSObject

/// 模型数据字典(对应 [JwSkiner shared].skinKeys作为字典key)
@property (nonatomic, strong) NSDictionary *param;
/// 模型数据数组(对应 [JwSkiner shared].skinKeys)
@property (nonatomic, strong) NSArray<NSString *> *params;
/// 模型key
@property (nonatomic, strong) NSString *key;

/// 快捷创建
/// sel: _cmd
/// param: 字典 (对应 [JwSkiner shared].skinKeys作为字典key)
+ (JwSkinerModel *)modelWithSel:(SEL)sel param:(NSDictionary *)param;

/// 快捷创建
/// sel: _cmd
/// params: 数组 (对应 [JwSkiner shared].skinKeys)
+ (JwSkinerModel *)modelWithSel:(SEL)sel params:(NSArray *)params;

/// MARK: 获取当前颜色
- (UIColor *)color;

/// MARK: 获取当前值
- (NSString *)value;

@end

@protocol JwSkinerColorDelegate <NSObject>

@optional

// Frame
+ (JwSkinerModel *)jw_theme;
+ (JwSkinerModel *)jw_back;
+ (JwSkinerModel *)jw_title;
+ (JwSkinerModel *)jw_value;


@end

/// MARK: 皮肤管理器
@interface JwSkiner : NSObject

/// 主题颜色指定类
@property (nonatomic, strong) Class<JwSkinerColorDelegate> colorClass;

/// 主题数组 默认@[@"any", @"light", @"dark"]
@property (nonatomic, strong, readonly) NSArray *skinKeys;
/// 当前的主题key
@property (nonatomic, strong, readonly) NSString *currentSkinKey;
/// 当前的主题下标
@property (nonatomic, assign, readonly) NSInteger currentSkinIndex;
/// 主题数组 图片后缀别名 默认@[@"a", @"l", @"d"]
@property (nonatomic, strong, readonly) NSArray *skinImageSuffixKeys;

/// 图片管理方式 默认 JwSkinerImageExUnknow
@property (nonatomic, assign) JwSkinerImageEx skinImageEx;

/// 单例
+ (JwSkiner *)shared;

/// 设置主题数组 默认@[@"any", @"light", @"dark"]
- (void)setupSkinKeys:(NSArray *)keys;

/// 设置主题数组 图片后缀别名 默认@[@"a", @"l", @"d"] (对应skinKeys 设置)
- (BOOL)setupSkinImageSuffixKeys:(NSArray *)keys;

/// 当前主题图片后缀别名
- (NSString *)currentSkinImageSuffixKey;

/// 设置主题
- (BOOL)setupCurrentSkinKey:(NSString *)key;

/// 设置主题
- (BOOL)setupCurrentSkinIndex:(NSUInteger)index;

/// 发送通知
- (void)postNoti;

// MARK: - property

// Frame
@property (nonatomic, strong) JwSkinerModel *jw_theme;
@property (nonatomic, strong) JwSkinerModel *jw_back;
@property (nonatomic, strong) JwSkinerModel *jw_title;
@property (nonatomic, strong) JwSkinerModel *jw_value;

/// 设置FrameProperty
- (void)setupFrameProperty;


@end

NS_ASSUME_NONNULL_END
